﻿Imports System.Data.Linq
Imports System.Linq
Imports TNCDAL

Public Class ucLoHangThanhToanCham
    Dim mad As New MAdvanceVoucher
    Dim mpm As New MPaymentVoucher
    Dim uti As New Utilities


    Private Sub ucLoHangThanhToanCham_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            ' Thanh toán hãng tàu chậm
            'Thời hạn tối đa phải mang hóa đơn về sau khi thanh toán hãng tàu
            Dim query = mad.GetListDetailAdvanceSlow(uti.GetTime_HangTau)
            gridhangtauhoadon.DataSource = query
            'Chèn thông tin FileNo vào danh sách đã có
            gridhangtauhoadon.Columns(0).Visible = False
            Format()
            For index = 0 To gridhangtauhoadon.RowCount - 1
                gridhangtauhoadon.Rows(index).Cells(7).Value = mad.GetFileNoOfAdvance(gridhangtauhoadon.Rows(index).Cells(0).Value)
                gridhangtauhoadon.Rows(index).Cells(8).Value = mad.GetTypeFileOfAdvance(gridhangtauhoadon.Rows(index).Cells(0).Value)
            Next

            query = mpm.GetListDetailPaymentSlow(uti.GetTime_KhachHang())
            gridkhachhang.DataSource = query
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    
    End Sub
    Public Sub Format()
        gridhangtauhoadon.Columns(4).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
        gridhangtauhoadon.Columns(5).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
        gridhangtauhoadon.Columns(5).DefaultCellStyle.Format = "#,##0.##"


    End Sub
    Private Sub gridhangtauhoadon_RowEnter(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles gridhangtauhoadon.RowEnter
        'Hiển thị chi tiết các file thuộc advance bị chậm
        'Dim query = mad.GetListFileOrContOfAdvanceSlow(gridhangtauhoadon.Rows(e.RowIndex).Cells(0).Value)

    End Sub

    Private Sub gridhangtauhoadon_DataBindingComplete(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewBindingCompleteEventArgs) Handles gridhangtauhoadon.DataBindingComplete
        'Format 
    End Sub
End Class
